package com.hliu.core.service.impl;

import com.hliu.core.dao.IBaseHibernateDao;
import com.hliu.core.service.IBaseHibernateService;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.List;


/**
 * author: 6
 * date: 13-4-8
 */
public abstract class BaseHibernateService<T extends Serializable, PK extends Serializable> implements IBaseHibernateService<T, PK> {
	Logger logger = LoggerFactory.getLogger(BaseHibernateService.class);


	protected IBaseHibernateDao<T, PK> iBaseDao;

	public abstract void setiBaseDao(IBaseHibernateDao<T, PK> iBaseDao);

	@Override
	public T get(PK id) {
		return iBaseDao.get(id);
	}

	@Override
	public T load(PK id) {
		return iBaseDao.load(id);
	}

	@Override
	public void save(T t) {
		iBaseDao.save(t);
	}

	@Override
	public void update(T t) {
		iBaseDao.update(t);
	}

	@Override
	public List<T> list() {
		return iBaseDao.list();
	}

	@Override
	public void saveOrUpdate(T t) {
		iBaseDao.saveOrUpdate(t);
	}

	@Override
	public void delete(T t) {
		iBaseDao.delete(t);
	}

	@Override
	public void del(PK id) {
		iBaseDao.del(id);
	}

	@Override
	public SQLQuery createSQLQuery(String queryString) {
		return iBaseDao.createSQLQuery(queryString);
	}

	@Override
	public Criteria createCriteria() {
		return iBaseDao.createCriteria();
	}

	@Override
	public Query createQuery(String queryString) {
		return iBaseDao.createQuery(queryString);
	}
}
